<article id="wikiArticle">
<div>
<p></p><p></p>
<p><code><strong>Error.prototype</strong></code> 属性代表 <a href="Reference/Global_Objects/Error" title="通过Error的构造器可以创建一个错误对象。当运行时错误产生时，Error的实例对象会被抛出。Error对象也可用于用户自定义的异常的基础对象。下面列出了各种内建的标准错误类型。"><code>Error</code></a> 的构造器。</p>
<p></p><table class="standard-table">
<thead>
<tr>
<th class="header" colspan="2"><code>Error.prototype</code> 属性的属性特性：</th>
</tr>
</thead>
<tbody>
<tr>
<td>writable</td>
<td>false</td>
</tr>
<tr>
<td>enumerable</td>
<td>false</td>
</tr>
<tr>
<td>configurable</td>
<td>false</td>
</tr>
</tbody>
</table><p></p>
</div>
<h2 id="Description" name="Description">描述</h2>
<p>所有 <a href="Reference/Global_Objects/Error" title="通过Error的构造器可以创建一个错误对象。当运行时错误产生时，Error的实例对象会被抛出。Error对象也可用于用户自定义的异常的基础对象。下面列出了各种内建的标准错误类型。"><code>Error</code></a> 与 <a href="Reference/Global_Objects/Error#Error_types" title="通过Error的构造器可以创建一个错误对象。当运行时错误产生时，Error的实例对象会被抛出。Error对象也可用于用户自定义的异常的基础对象。下面列出了各种内建的标准错误类型。">非标准Error</a> 的实例都继承自 <code>Error.prototype。同所有构造器函数一样，你可以在构造器的 </code>prototype 上添加属性或者方法，使其在所有该构造器的实例上生效。</p>
<h2 id="Properties" name="Properties">属性</h2>
<h3 id="Standard_properties" name="Standard_properties">标准属性</h3>
<dl>
<dt><code>Error.prototype.constructor</code></dt>
<dd>实例原型的构造函数。</dd>
<dt><a href="Reference/Global_Objects/Error/message" title="message 属性是有关错误信息，人类易读的（human-readable）描述。"><code>Error.prototype.message</code></a></dt>
<dd>错误信息。</dd>
<dt><a href="Reference/Global_Objects/Error/name" title='name 属性表示error类型的名称.初始值为"Error".'><code>Error.prototype.name</code></a></dt>
<dd>错误名。</dd>
</dl>
<h3 id="Vendor-specific_extensions" name="Vendor-specific_extensions">厂商特定扩展属性</h3>
<div><div class="blockIndicator nonStandard nonStandardHeader">
<p><strong><span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span> 非标准</strong><br/>
      该特性是非标准的，请尽量不要在生产环境中使用它！</p>
</div></div>
<h4 id="Microsoft" name="Microsoft">Microsoft</h4>
<dl>
<dt><a class="new" href="Reference/Global_Objects/Error/description" rel="nofollow" title="此页面仍未被本地化, 期待您的翻译!"><code>Error.prototype.description</code></a></dt>
<dd>错误描述，与 <a href="Reference/Global_Objects/Error/message" title="message 属性是有关错误信息，人类易读的（human-readable）描述。"><code>message</code></a> 相似。</dd>
<dt><a class="new" href="Reference/Global_Objects/Error/number" rel="nofollow" title="此页面仍未被本地化, 期待您的翻译!"><code>Error.prototype.number</code></a></dt>
<dd>错误码。</dd>
</dl>
<h4 id="Mozilla" name="Mozilla">Mozilla</h4>
<dl>
<dt><a href="Reference/Global_Objects/Error/fileName" title="fileName 属性包含引发此错误的文件的路径."><code>Error.prototype.fileName</code></a></dt>
<dd>产生该错误的文件名。</dd>
<dt><a href="Reference/Global_Objects/Error/lineNumber" title="lineNumber 属性的值为抛出错误的代码在其源文件中所在的行号。"><code>Error.prototype.lineNumber</code></a></dt>
<dd>产生该错误的行号。</dd>
<dt><a href="Reference/Global_Objects/Error/columnNumber" title="columnNumber属性包含引发此错误的文件行中的列号。"><code>Error.prototype.columnNumber</code></a></dt>
<dd>产生该错误的列号。</dd>
<dt><a href="Reference/Global_Objects/Error/stack" title="Error对象作为一个非标准的栈属性提供了一种函数追踪方式。无论这个函数被被调用，处于什么模式，来自于哪一行或者哪个文件，有着什么样的参数。这个栈产生于最近一次调用最早的那次调用，返回原始的全局作用域调用"><code>Error.prototype.stack</code></a></dt>
<dd>错误堆栈。</dd>
</dl>
<h2 id="Methods" name="Methods">方法</h2>
<dl>
<dt><a href="Reference/Global_Objects/Error/toSource" title="toSource() 方法返回可以计算出到相同错误的代码。"><code>Error.prototype.toSource()</code></a> <span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span></dt>
<dd>返回一个包含特定 <a href="Reference/Global_Objects/Error" title="通过Error的构造器可以创建一个错误对象。当运行时错误产生时，Error的实例对象会被抛出。Error对象也可用于用户自定义的异常的基础对象。下面列出了各种内建的标准错误类型。"><code>Error</code></a> 对象的源代码字符串，你可以用该值新建一个新的对象，重写自 <a href="Reference/Global_Objects/Object/toSource" title="toSource()方法返回一个表示对象源代码的字符串。"><code>Object.prototype.toSource()</code></a> 方法。</dd>
<dt><a href="Reference/Global_Objects/Error/toString" title="toString() 方法返回一个指定的错误对象（Error object）的字符串表示。"><code>Error.prototype.toString()</code></a></dt>
<dd>返回一个表示该对象的字符串，重写自 <a href="Reference/Global_Objects/Object/toString" title="toString() 方法返回一个表示该对象的字符串。"><code>Object.prototype.toString()</code></a> 方法。</dd>
</dl>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">规范版本</th>
<th scope="col">状态</th>
<th scope="col">注解</th>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf" hreflang="en" lang="en" rel="noopener" title="ECMAScript 1st Edition (ECMA-262)">ECMAScript 1st Edition (ECMA-262)</a></td>
<td><span class="spec-Standard">Standard</span></td>
<td>Initial definition. Implemented in JavaScript 1.1.</td>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.3.1" hreflang="en" lang="en" rel="noopener">ECMAScript 5.1 (ECMA-262)<br/><small lang="zh-CN">Error</small></a></td>
<td><span class="spec-Standard">Standard</span></td>
<td> </td>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-error.prototype" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">Error</small></a></td>
<td><span class="spec-Standard">Standard</span></td>
<td> </td>
</tr>
<tr>
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-error.prototype" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">Error</small></a></td>
<td><span class="spec-Draft">Draft</span></td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<div><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
            This compatibility table still uses the old format,
            because we haven't yet converted the data it contains.
            <strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div></div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
</tr>
</tbody>
</table>
</div>
<h2 id="See_also" name="See_also">参见</h2>
<ul>
<li><a href="Reference/Global_Objects/Error" title="通过Error的构造器可以创建一个错误对象。当运行时错误产生时，Error的实例对象会被抛出。Error对象也可用于用户自定义的异常的基础对象。下面列出了各种内建的标准错误类型。"><code>Error</code></a></li>
<li><a href="Reference/Global_Objects/Object/prototype" title="Object.prototype 属性表示 Object 的原型对象。"><code>Object.prototype</code></a></li>
</ul>
</article>